package com.anolesoft.amljmes.fortyone.service.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import com.anolesoft.amljmes.fortyone.entity.MesGjgyxxFksz;

import cn.hutool.core.util.StrUtil;

/**
 * 对应表 mes_gjgyxx_fksz
 * 
 * @author 陈向前
 *
 */
@Mapper
public interface MesGjgyxxFkszMapper {
	@SelectProvider(type = SQLBuilder.class, method = "queryMesGjgyxxFkszForSelectSQL")
	List<MesGjgyxxFksz> queryMesGjgyxxFkszForSelect(@Param(value = "gyffjc") String gyffjc,
			@Param(value = "factoryId") String factoryId);

	class SQLBuilder {
		public String queryMesGjgyxxFkszForSelectSQL(@Param(value = "gyffjc") String gyffjc,
				@Param(value = "factoryId") String factoryId) {
			return new SQL() {
				{
					SELECT("objuid, gyffjc");
					FROM("mes_gjgyxx_fksz");
					WHERE("factory_id = #{factoryId}");
					if (!StrUtil.isEmptyOrUndefined(gyffjc)) {
						WHERE("instr(upper(gyffjc), upper(trim(#{gyffjc}))) > 0 ");
					}
					ORDER_BY("gyffjc");
				}
			}.toString();
		}
	}
}
